package Cordiali_Es2;

import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

public class IndexWriter {
	private ArrayList<IndexCollector> indexCollector;
	private String filename;
	
	public IndexWriter(String filename) {
		super();
		this.filename = filename;
		this.indexCollector = new ArrayList<IndexCollector>();
	}
	
	public void addIndexCollector(IndexCollector ic) {
		this.indexCollector.add(ic);
	}
	
	public ArrayList<IndexCollector> getIndexCollector() {
		return indexCollector;
	}

	public void setIndexCollector(ArrayList<IndexCollector> indexCollector) {
		this.indexCollector = indexCollector;
	}

	public String getFilename() {
		return filename;
	}
	
	public void setFilename(String filename) {
		this.filename = filename;
	}
	
	public void writeToFile() {
		FileWriter fw;
		try {
			fw = new FileWriter(this.filename);
			for (IndexCollector ic : this.indexCollector) {
				fw.write(ic.toString() + "\n");
			}
			fw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
//	public void appendToFile() {
//		
//	}
}
